home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_bas / t2win_32.zip / _ENCRYPT.FRM < prev    next >
Text File  |  1996-05-14  |  8KB  |  292 lines

  1. VERSION 4.00
  2. Begin VB.Form frmEncrypt 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Encrypt - Decrypt"
  5.    ClientHeight    =   4845
  6.    ClientLeft      =   1890
  7.    ClientTop       =   3270
  8.    ClientWidth     =   7485
  9.    Height          =   5250
  10.    Left            =   1830
  11.    MaxButton       =   0   'False
  12.    MDIChild        =   -1  'True
  13.    ScaleHeight     =   4845
  14.    ScaleWidth      =   7485
  15.    ShowInTaskbar   =   0   'False
  16.    Top             =   2925
  17.    Width           =   7605
  18.    Begin VB.TextBox txt_Result 
  19.       BackColor       =   &H00C0C0C0&
  20.       BorderStyle     =   0  'None
  21.       Height          =   4110
  22.       Left            =   105
  23.       Locked          =   -1  'True
  24.       MultiLine       =   -1  'True
  25.       ScrollBars      =   2  'Vertical
  26.       TabIndex        =   0
  27.       Top             =   630
  28.       Width           =   7260
  29.    End
  30.    Begin Threed.SSPanel SSPanel1 
  31.       Align           =   1  'Align Top
  32.       Height          =   480
  33.       Left            =   0
  34.       TabIndex        =   1
  35.       Top             =   0
  36.       Width           =   7485
  37.       _Version        =   65536
  38.       _ExtentX        =   13203
  39.       _ExtentY        =   847
  40.       _StockProps     =   15
  41.       ForeColor       =   -2147483640
  42.       BackColor       =   12632256
  43.       Begin VB.ComboBox cmb_Function 
  44.          Height          =   315
  45.          Left            =   1365
  46.          TabIndex        =   2
  47.          Top             =   90
  48.          Width           =   4785
  49.       End
  50.       Begin Threed.SSCommand cmdNP 
  51.          Height          =   300
  52.          Index           =   1
  53.          Left            =   7140
  54.          TabIndex        =   6
  55.          Top             =   90
  56.          Width           =   255
  57.          _Version        =   65536
  58.          _ExtentX        =   450
  59.          _ExtentY        =   529
  60.          _StockProps     =   78
  61.          Caption         =   ">"
  62.          BevelWidth      =   1
  63.          Font3D          =   3
  64.          RoundedCorners  =   0   'False
  65.          Outline         =   0   'False
  66.       End
  67.       Begin Threed.SSCommand cmdNP 
  68.          Height          =   300
  69.          Index           =   0
  70.          Left            =   6300
  71.          TabIndex        =   5
  72.          Top             =   90
  73.          Width           =   255
  74.          _Version        =   65536
  75.          _ExtentX        =   450
  76.          _ExtentY        =   529
  77.          _StockProps     =   78
  78.          Caption         =   "<"
  79.          BevelWidth      =   1
  80.          Font3D          =   3
  81.          RoundedCorners  =   0   'False
  82.          Outline         =   0   'False
  83.       End
  84.       Begin VB.Label Label2 
  85.          Caption         =   "&Select a function"
  86.          Height          =   255
  87.          Left            =   90
  88.          TabIndex        =   4
  89.          Top             =   120
  90.          Width           =   1275
  91.       End
  92.       Begin Threed.SSCommand SSCommand1 
  93.          Default         =   -1  'True
  94.          Height          =   300
  95.          Left            =   6615
  96.          TabIndex        =   3
  97.          Top             =   90
  98.          Width           =   465
  99.          _Version        =   65536
  100.          _ExtentX        =   820
  101.          _ExtentY        =   529
  102.          _StockProps     =   78
  103.          Caption         =   "&Go"
  104.          BevelWidth      =   1
  105.          RoundedCorners  =   0   'False
  106.          Outline         =   0   'False
  107.       End
  108.    End
  109. End
  110. Attribute VB_Name = "frmEncrypt"
  111. Attribute VB_Creatable = False
  112. Attribute VB_Exposed = False
  113. Option Explicit
  114. Option Base 1
  115.  
  116. Private Const Iteration = 25
  117.  
  118. Dim IsLoaded         As Integer
  119.  
  120. Dim TimerStartOk     As Integer
  121. Dim TimerCloseOk     As Integer
  122.  
  123. Dim TimerHandle      As Integer
  124. Dim TimerValue       As Long
  125.  
  126. Private Sub cmdNP_Click(Index As Integer)
  127.  
  128.    Call sub_NextPrev(cmb_Function, Index)
  129.  
  130. End Sub
  131.  
  132.  
  133. Private Sub cmb_Function_Click()
  134.    
  135.    If (IsLoaded = False) Then Exit Sub
  136.    
  137.    Call cDisableFI(mdiT2W.Picture1)
  138.    
  139.    txt_Result = ""
  140.    
  141.    DoEvents
  142.    
  143.    Select Case cmb_Function.ListIndex
  144.       Case 0
  145.          Call TestFileEncrypt
  146.       Case 1
  147.          Call TestStringEncrypt
  148.    End Select
  149.  
  150.    DoEvents
  151.    Call cEnableFI(mdiT2W.Picture1)
  152.    
  153. End Sub
  154.  
  155.  
  156. Private Sub Form_Activate()
  157.  
  158.    mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
  159.  
  160. End Sub
  161.  
  162. Private Sub Form_Load()
  163.  
  164.    IsLoaded = False
  165.    
  166.    Show
  167.  
  168.    Call sub_Load_Combo(cmb_Function, T2WDirInst + "_encrypt.t2w")
  169.    
  170.    IsLoaded = True
  171.    
  172. End Sub
  173.  
  174. Private Sub SSCommand1_Click()
  175.    
  176.    Call cmb_Function_Click
  177.    
  178. End Sub
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186. Private Sub TestFileEncrypt()
  187.  
  188.    Dim lngResult        As Long
  189.    Dim strResult        As String
  190.    Dim strDisplay       As String
  191.    
  192.    Dim i                As Integer
  193.    
  194.    Dim File1            As String
  195.    Dim File2            As String
  196.    Dim File3            As String
  197.    Dim Key              As String
  198.    
  199.    strResult = ""
  200.    strDisplay = ""
  201.    
  202.    File1 = T2WFileTest
  203.    File2 = "autoexec.encrypted"
  204.    File3 = "autoexec.decrypted"
  205.    Key = "1234567890"
  206.  
  207.    For i = ENCRYPT_LEVEL_0 To ENCRYPT_LEVEL_4
  208.       strDisplay = strDisplay & "Encrypt (level " & i & ") '" & File1 & "' with '?' to '" & File2 & "' is " & cFileEncrypt(File1, File2, Key, i) & vbCrLf
  209.       strDisplay = strDisplay & "Decrypt (level " & i & ") '" & File2 & "' with '?' to '" & File3 & "' is " & cFileDecrypt(File2, File3, Key, i) & vbCrLf
  210.       strDisplay = strDisplay & "Compare (ns) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  211.    Next i
  212.  
  213.    txt_Result = strDisplay
  214.  
  215.    'time the function
  216.  
  217.    TimerHandle = cTimerOpen()
  218.    TimerStartOk = cTimerStart(TimerHandle)
  219.    
  220.    For i = 1 To Iteration
  221.       lngResult = cFileEncrypt(File1, File2, Key, ENCRYPT_LEVEL_3)
  222.    Next i
  223.    
  224.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  225.    
  226.    TimerCloseOk = cTimerClose(TimerHandle)
  227.  
  228. End Sub
  229.  
  230. Public Sub TestStringEncrypt()
  231.  
  232.    Dim lngResult        As Long
  233.    Dim strResult        As String
  234.    Dim strDisplay       As String
  235.    
  236.    Dim i                As Integer
  237.    
  238.    Dim Str1             As String
  239.    Dim Str2             As String
  240.    Dim Key              As String
  241.    
  242.    strResult = ""
  243.    strDisplay = ""
  244.    
  245.    Str1 = "T2WIN-32, t2win-32"
  246.    Key = "1234567890"
  247.  
  248.    For i = ENCRYPT_LEVEL_0 To ENCRYPT_LEVEL_4
  249.       Str2 = cEncrypt(Str1, Key, i)
  250.       strDisplay = strDisplay & "Encrypt (level " & i & ") of [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  251.       strDisplay = strDisplay & "Decrypt (level " & i & ") of [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDecrypt(Str2, Key, i) & "]" & vbCrLf & vbCrLf
  252.    Next i
  253.    
  254.    strDisplay = strDisplay & vbCrLf
  255.  
  256.    Str1 = "Windows 95 : Hints and Tips"
  257.  
  258.    For i = ENCRYPT_LEVEL_0 To ENCRYPT_LEVEL_4
  259.       Str2 = cEncrypt(Str1, Key, i)
  260.       strDisplay = strDisplay & "Encrypt (level " & i & ") of [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  261.       strDisplay = strDisplay & "Decrypt (level " & i & ") of [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDecrypt(Str2, Key, i) & "]" & vbCrLf & vbCrLf
  262.    Next i
  263.   
  264.    strDisplay = strDisplay & vbCrLf
  265.  
  266.    Str1 = "Under the sky, the sun lights"
  267.    
  268.    For i = ENCRYPT_LEVEL_0 To ENCRYPT_LEVEL_4
  269.       Str2 = cEncrypt(Str1, Key, i)
  270.       strDisplay = strDisplay & "Encrypt (level " & i & ") of [" & Str1 & "] with '?' is [" & cFilterChars(Str2, Chr$(0)) & "]" & vbCrLf
  271.       strDisplay = strDisplay & "Decrypt (level " & i & ") of [" & cFilterChars(Str2, Chr$(0)) & "] with '?' is [" & cDecrypt(Str2, Key, i) & "]" & vbCrLf & vbCrLf
  272.    Next i
  273.    
  274.    strDisplay = strDisplay & vbCrLf
  275.  
  276.    txt_Result = strDisplay
  277.  
  278.    'time the function
  279.  
  280.    TimerHandle = cTimerOpen()
  281.    TimerStartOk = cTimerStart(TimerHandle)
  282.    
  283.    For i = 1 To Iteration
  284.       strResult = cEncrypt(Str1, Key, ENCRYPT_LEVEL_3)
  285.    Next i
  286.    
  287.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  288.    
  289.    TimerCloseOk = cTimerClose(TimerHandle)
  290.  
  291. End Sub
  292.